package net.homelinux.chaoswg.io.renga.krypto.operations.vector;

import net.homelinux.chaoswg.io.higherorderfunctions.AbstractUnaryFunction;
import net.homelinux.chaoswg.io.higherorderfunctions.UnaryFunction;
import net.homelinux.chaoswg.io.renga.krypto.datatypes.vectors.BitVector;

public class Ror extends AbstractUnaryFunction<BitVector, BitVector> implements UnaryFunction<BitVector, BitVector> {
    public final BitVector apply (final BitVector b0) {
        final BitVector toReturn = new BitVector (b0.getSize());

        for (int i = toReturn.getSize() - 1 ; i >= 0; --i) {
            int j = (i-1) >= 0 ? (i-1) : toReturn.getSize () - 1; 
            toReturn.set(i, b0.get(j));
        }
        return toReturn;
    }

    public String toString () {
        return "Rotate Right";
    }
}
